/**
 * Title:        流程版本信息表数据检测
 * Company:      泛微软件
 */


package checkWithCondit;

import general.BaseBean;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import org.json.JSONObject;

import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.hrm.User;
import weaver.workflow.ruleDesign.RuleBusiness;
import checkDetail.CheckBase;



public class NodeLinkConditionCheck extends BaseBean implements checkWithConBase  {

    @Override
    public JSONObject checkData(HashMap dataMap) {
        setRecordSet();
        RecordSet RecordSet1 = new RecordSet();
        (new BaseBean()).writeLog("WorkflowVersionCheck  start");
        List resultList = new ArrayList();
        String result = "";
        if(dataMap.get("requestid") != null && !dataMap.get("requestid").equals("")){

            User user = new User(1);
            String requestid = (String)dataMap.get("requestid");
            recordSet.executeSql("select distinct nodeid from workflow_currentoperator where requestid = " + requestid);
            while(recordSet.next()){
                String nodeid = recordSet.getString("nodeid");
                RecordSet1.execute("select linkname,newrule from workflow_nodelink where nodeid="+ nodeid);
                while(RecordSet1.next()){
                    String linkname = RecordSet1.getString("linkname");
                    String ruleids = RecordSet1.getString("newrule");
                    List<String> ruleidList = Util.splitString2List(ruleids, ",");
                    for(String ruleid : ruleidList){
                        String[] ruleInfoArray = RuleBusiness.getRuleHtmlByRuleId(Util.getIntValue(ruleid),user);
                        System.out.println("ruleInfoArray0==================" + ruleInfoArray[0]);
                        System.out.println("ruleInfoArray1==================" + ruleInfoArray[1]);
                    }
                }
            }
            if(0 == 0){
                result = resultOk;
            }else{
                result = resultNeedFix;
            }
            (new BaseBean()).writeLog("WorkflowVersionCheck  end");
        }else{
            result = resultERROR;
            resultList.add("请输入requestid");
        }
        return formatReturnJsonCheck(result, resultList, this);
    }

    @Override
    public JSONObject fixData(HashMap dataMap) {

        //重新加载DIV
        needReload = "1";
        return checkData(new HashMap());
    }

    @Override
    public String getClassName() {
        return "出口条件和操作者检测(编码中)";
    }

    @Override
    public String getClassDesc() {
        return "检测出口条件和操作者条件是否满足";
    }

    @Override
    public String getPopupUrl() {
        return "/flowtoolbar/checkWithCondit/NodeLinkConditionCheck.jsp";
    }

}



